package api

import (
	"animal/octopus/common"
	"animal/octopus/core"
	"net/http"

	"github.com/gin-gonic/gin"
	log "github.com/sirupsen/logrus"
)

// ------------------------------------------------------------------------------
//
// ------------------------------------------------------------------------------
func GetDependencyList(c *gin.Context) {
	log.WithFields(log.Fields{"request": c.Request}).Info(c.Request.URL.Path)

	moduleID, err := common.GetRequestIntParam(c, "module")
	if err != nil {
		c.PureJSON(http.StatusBadRequest, gin.H{
			"code":   common.ErrInvalidParam,
			"msg":    err.Error(),
			"result": nil,
		})
		return
	}

	c.PureJSON(http.StatusOK, gin.H{
		"code":    0,
		"type":    "success",
		"message": "success",
		"result":  core.GetDependencyList(nil, uint(moduleID)),
	})
}
